#!/bin/bash

echo "cn.kawins 2018-9-18"

set -e

if [[ `docker ps --filter name=${1} | grep ${1}` ]];
then
    docker stop ${1}
fi;

if [[ `docker ps -a --filter name=${1} | grep ${1}` ]];
then
	docker rm ${1}
fi;

if [[ `docker images ${1} | grep ${1}` ]];
then
	docker rmi ${1}:${3}
fi;

docker build -t ${1}:${3} /opt/${1}